<?php
require_once("../../inc/global.php");
require_once("function.php");
adminislogin();
$MenuID=$_GET["MenuID"];
function getpostval($u){
	if(!isset($_POST[$u])) return '';
	return $_POST[$u];
}
if(strtolower($_SERVER['REQUEST_METHOD'])=='post'){
	
	$menusys0 = $_POST['SysMenu0'];
	$menusys1 = $_POST['SysMenu1'];
	$menusys4 = getpostval('SysMenu4');
	$menusys3 = $_POST['SysMenu3'];
	$menusys13 = getpostval('SysMenu13');
	$menusys19 = getpostval('SysMenu19');
	$mmenusys13 = getpostval('mSysMenu13');
	$mmenusys19 = getpostval('mSysMenu19');
	$menusys12 = getpostval('SysMenu12');
	$menusys20 = getpostval('SysMenu20');
	$mmenusys12 = getpostval('mSysMenu12');
	$mmenusys20 = getpostval('mSysMenu20');
	$menusys18 = getpostval('htmlclass');
	$menusys14 = getpostval('SysMenu14');
	$menusys15 = getpostval('SysMenu15');
	$mmenusys14 = getpostval('mSysMenu14');
	$mmenusys15 = getpostval('mSysMenu15');
	$menusys16 = getpostval('SysMenu16');
	$menusys17 = getpostval('SysMenu17');
	$mmenusys16 = getpostval('mSysMenu16');
	$mmenusys17 = getpostval('mSysMenu17');

	if(isset($_POST["SysMenu4"])){
		$SysMenu4=$_POST["SysMenu4"];
	}
	if(empty($SysMenu4)){
		if($db->query('update menusys set menusys1="'.$menusys1.'",menusys3="'.$menusys3.'" where menusys0='.$menusys0.' limit 1')){
			YKT_refresh_path("../../left.php");
			YKT_error('栏目修改成功！！','/'.ADMINROOT.'/System/menusys/index.php');
		}else{
			YKT_refresh_path("../../left.php");
			YKT_error('栏目修改失败！！','/'.ADMINROOT.'/System/menusys/index.php');
		}
	}else{
		$SysMenuArr=explode("|",$menusys4);
		if($db->query('update menusys set menusys1="'.$menusys1.'",menusys1 = "'.$menusys1.'",menusys3 = "'.$menusys3.'",menusys10 = "'.$SysMenuArr[0].'",menusys11 = "'.$SysMenuArr[1].'",menusys8 = "'.$SysMenuArr[2].'",menusys13 = "'.$menusys13.'",menusys19 = "'.$menusys19.'",mmenusys13 = "'.$mmenusys13.'",mmenusys19 = "'.$mmenusys19.'",menusys12 = "'.$menusys12.'",menusys20 = "'.$menusys20.'",mmenusys12 = "'.$mmenusys12.'",mmenusys20 = "'.$mmenusys20.'",menusys18 = "'.$menusys18.'",menusys14 = "'.$menusys14.'",menusys15 = "'.$menusys15.'",mmenusys14 = "'.$mmenusys14.'",mmenusys15 = "'.$mmenusys15.'",menusys16 = "'.$menusys16.'",menusys17 = "'.$menusys17.'",mmenusys16 = "'.$mmenusys16.'",mmenusys17 = "'.$mmenusys17.'" where menusys0='.$MenuID.' limit 1')){
			YKT_refresh_path("../../left.php");
			
			YKT_error('栏目修改成功！！','/'.ADMINROOT.'/System/menusys/index.php');
		}else{
			YKT_refresh_path("../../left.php");
			YKT_error('栏目修改失败！！','/'.ADMINROOT.'/System/menusys/update.php?MenuID='.$MenuID);
		}
		
		/*
		if($db->query("update menusys set menusys1='{$SysMenu1}',menusys3={$SysMenu3},menusys10='{$SysMenuArr[0]}',menusys11='{$SysMenuArr[1]}',menusys8='{$SysMenuArr[2]}',menusys12='{$SysMenu12}',menusys13='{$SysMenu13}',menusys14='{$SysMenu14}',menusys15='{$SysMenu15}',menusys16='{$SysMenu16}',menusys17='{$SysMenu17}',menusys18='{$htmlclass}',menusys19='{$SysMenu19}' where menusys0={$SysMenu0} limit 1")){
			YKT_refresh_path("../../left.php");
			YKT_error('栏目修改成功！！','/'.ADMINROOT.'/System/MenuSys/index.php');
		}
		else
		{
			YKT_refresh_path("../../left.php");
			YKT_error('栏目修改失败！！','/'.ADMINROOT.'/System/MenuSys/index.php');
		}
		*/
	}
	
}
else
{
	if(empty($MenuID) || !is_numeric($MenuID)){
		YKT_refresh_path("../../left.php");  //刷新左边
		YKT_error('参数不正确，无法修改！！',$_SERVER["HTTP_REFERER"]);
	}
	$row=$db->getoners("select * from menusys where menusys0=".$MenuID." limit 1");
	if(empty($row['menusys8']) || empty($row['menusys10']) || empty($row['menusys11'])){
		$html->includetop();
		$html->updateMenu($MenuID,0);
		$html->includeend();
	}else{
		$classlist=$db->getlistarr("select * from menusys where menusys8='classsys' Order by menusys0 desc");	
		$classstr='';
		foreach($classlist as $val){
			$classstr.="<option value='".$val[0]."'>".$val[1]."</option>";
		}
		?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>系统管理</title>
<link href="/webadmin/Css.css" rel="stylesheet" type="text/css">
</head>

<body >
当前位置：添加下级栏目&nbsp;>&nbsp;添加栏目
<script charset="utf-8" src="./js/jquery.min.js"></script>
<form id="form1" name="form1" method="post" action="?MenuID=<?php echo $MenuID;?>">
  <p>&nbsp;</p>
  <p>&nbsp;</p>
  <input name="SysMenu0" type="hidden"  value="<?php echo $row['menusys0'];?>" size="30" />
  <div style="width:700px; margin:0 auto">
    <fieldset style="border:#999 solid 1px; border-radius:4px">
      <legend>栏目属性</legend>
      <table width="95%" border="0" align="center">
        <tr>
          <td width="150"><div align="right">栏目名称：</div></td>
          <td><label>
              <input name="SysMenu1" id="SysMenu1"  value="<?php echo $row['menusys1'];?>" type="text" size="30" />
            </label></td>
        </tr>
        <tr>
          <td><div align="right">栏目功能：</div></td>
          <td><label>
              <select name="SysMenu4" class="menudrops" id="SysMenu4">
                <option value=""  selected>请选择...</option>
                <?php
				$res=$db->query("select * from system");
				while($rows=$db->getarray($res)){
					echo "<option value=\"".$rows['system2']."|".$rows['system1']."|".$rows['system3']."\">".$rows['system1']."</option>\n";
				}
				?>
              </select>
              <script type="text/javascript">document.getElementById("SysMenu4").value="<?php echo $row['menusys10'];?>|<?php echo $row['menusys11'];?>|<?php echo $row['menusys8'];?>"</script> 
            </label>
            <a href="selftable.php" style="color:#F00" title="如果没有合适的功能可以自定义">自定义系统管理>></a></td>
        </tr>
        <tr>
          <td><div align="right">复制样式：</div></td>
          <td><select name="ListMenuSys">
              <option value="" selected="selected">请选择...</option>
            </select></td>
        </tr>
        <tr>
          <td><div align="right">排序：</div></td>
          <td><label>
              <input name="SysMenu3" id="SysMenu3" type="text" value="<?php echo $row['menusys3'];?>" size="10" />
              *请输入数字 </label></td>
        </tr>
      </table>
    </fieldset>
    <fieldset id="staticsettings1" style="border:#999 solid 1px; display:none; margin-top:10px; border-radius:4px">
      <legend>单页静态设置</legend>
      <table width="95%" border="0" align="center">
      	
        <tr>
          <td width="150"><div align='right'>单页模板：</div></td>
          <td><input name='SysMenu13' id='SysMenu13' value='<?php echo $row['menusys13'];?>' type='text' size='30' />
            如:about.html</td>
        </tr>
        <tr>
          <td><div align='right'>生成地址：</div></td>
          <td><input name='SysMenu19' id='SysMenu19' value='<?php echo $row['menusys19'];?>' type='text' size='30' />
            如:about.html</td>
        </tr>
        <tr>
          <td><div align='right'>（移动端）单页模板：</div></td>
          <td><input name='mSysMenu13' id='mSysMenu13' value='<?php echo $row['mmenusys13'];?>' type='text' size='30' />
            如:about.html</td>
        </tr>
        <tr>
          <td><div align='right'>（移动端）生成地址：</div></td>
          <td><input name='mSysMenu19' id='mSysMenu19' value='<?php echo $row['mmenusys19'];?>' type='text' size='30' />
            如:about.html</td>
        </tr>
      </table>
    </fieldset>
    <fieldset id="staticsettings2" style="border:#999 solid 1px; display:none; margin-top:10px; border-radius:4px">
      <legend>频道静态设置</legend>
      <table width="95%" border="0" align="center">
      <tr>
      	<td width="150"><div align='right'>频道页模板：</div></td>
      	<td><input name='SysMenu12' id='SysMenu12' value='<?php echo $row['menusys12'];?>' type='text' size='30' /> 如:/api/index.php/index/news/</td>
      </tr>
      <tr>
      	<td><div align='right'>频道页地址：</div></td>
      	<td><input name='SysMenu20' id='SysMenu20' value='<?php echo $row['menusys20'];?>' type='text' size='30' /> 如:/api/index.php/index/news/</td>
      </tr>
      <tr>
      	<td><div align='right'>（移动端）频道页模板：</div></td>
      	<td><input name='mSysMenu12' id='mSysMenu12' value='<?php echo $row['mmenusys12'];?>' type='text' size='30' /> 如:/api/index.php/index/news/</td>
      </tr>
      <tr>
      	<td><div align='right'>（移动端）频道页地址：</div></td>
      	<td><input name='mSysMenu20' id='mSysMenu20' value='<?php echo $row['mmenusys20'];?>' type='text' size='30' /> 如:/api/index.php/index/news/</td>
      </tr>
     <tr>
      <td><div align='right'>按分类生成：</div></td>
      <td><select id='htmlclass' name='htmlclass'>
          <option value='0'>请选择</option>
          <?php echo $classstr; ?>
        </select>
        <script type="text/javascript">document.getElementById('htmlclass').value=<?php echo $row['menusys18'];?>;</script></td>
    </tr>
    <tr>
      <td><div align='right'>列表页静态：</div></td>
      <td><input name='SysMenu14' id='SysMenu14' value='<?php echo $row['menusys14'];?>' type='text' size='30' />
        如:/news/list{$cid}_{$page}.html</td>
    </tr>
    <tr>
      <td><div align='right'>列表页模板：</div></td>
      <td><input name='SysMenu15' id='SysMenu15' value='<?php echo $row['menusys15'];?>' type='text' size='30' />
        如:newslist.html</td>
    </tr>
    <tr>
      <td><div align='right'>（移动端）列表页静态：</div></td>
      <td><input name='mSysMenu14' id='mSysMenu14' value='<?php echo $row['mmenusys14'];?>' type='text' size='30' />
        如:/news/list{$cid}_{$page}.html</td>
    </tr>
    <tr>
      <td><div align='right'>（移动端）列表页模板：</div></td>
      <td><input name='mSysMenu15' id='mSysMenu15' value='<?php echo $row['mmenusys15'];?>' type='text' size='30' />
        如:newslist.html</td>
    </tr>
    <tr>
      <td><div align='right'>内容页静态：</div></td>
      <td><input name='SysMenu16' id='SysMenu16' value='<?php echo $row['menusys16'];?>' type='text' size='30' />
        如:/news/views{$id}.html</td>
    </tr>
    <tr>
      <td><div align='right'>内容页模板：</div></td>
      <td><input name='SysMenu17' id='SysMenu17' value='<?php echo $row['menusys17'];?>' type='text' size='30' />
        如:newsdetail.html</td>
    </tr>
    <tr>
      <td><div align='right'>（移动端）内容页静态：</div></td>
      <td><input name='mSysMenu16' id='mSysMenu16' value='<?php echo $row['mmenusys16'];?>' type='text' size='30' />
        如:/news/views{$id}.html</td>
    </tr>
    <tr>
      <td><div align='right'>（移动端）内容页模板：</div></td>
      <td><input name='mSysMenu17' id='mSysMenu17' value='<?php echo $row['mmenusys17'];?>' type='text' size='30' />
        如:newsdetail.html</td>
    </tr>
      </table>
    </fieldset>
    <table width="95%" border="0" style="margin-top:10px" align="center">
    <tr>
      <td width="120">&nbsp;</td>
      <td><label>
          <input type="submit" name="Submit" onclick="return yzadd()" style="background-image:url(../../iamges/botton_baocun.png); width:69px; border:0px; height:24px; background-repeat:no-repeat;" value=" " />
          <input type="button" name="Submit2" style="background-image:url(../../iamges/botton_quxiao.png); width:69px; border:0px; height:24px; background-repeat:no-repeat;" value=" " onClick="window.history.back();"/>
        </label></td>
    </tr>
      </table>
  </div>
</form>

<script type="text/javascript">
$(function(){
	$('#SysMenu4').change(function(){
		var text = $(this).find("option:selected").text();
		settings(text);
	});
	
	settings($('#SysMenu4').find("option:selected").text());
});
function settings(text){
	var nostaticstring = '系统设置|分类系统|权限系统|用户管理|友情链接|留言系统';
	if(text=='单页系统'){
		$('#staticsettings1').show();
		$('#staticsettings2').hide();
	}else if(text=='请选择...' || nostaticstring.indexOf(text)>=0){
		$('#staticsettings1,#staticsettings2').hide();
	}else{
		$('#staticsettings2').show();
		$('#staticsettings1').hide();
	}
}

$('#form1').submit(function(){
	if($("#SysMenu1").val().length < 1){
		alert("栏目名称,不能为空！！");
		$("#SysMenu1").focus();
		return false;
	}
	if($("#SysMenu4").val()==""){
		alert("请选择功能！！");
		$("#SysMenu4").focus();
		return false;
	}
	if($("#SysMenu3").val().length < 1){
		alert("排序,不能为空！！");
		$("#SysMenu3").focus();
		return false;
	}
});
</script>
</body>
</html>
		
		<?php
		
	}
	
	
}
?>

